package com.umpay.controller.consume;

import com.umpay.annotation.ReceiveEntity;
import com.umpay.business.consume.ConsumeBusinessService;
import com.umpay.controller.base.AbstractController;
import com.umpay.dto.UMFRequest;
import com.umpay.dto.UMFResponse.Message;
import com.umpay.dto.merAccess.req.consume.ConsumeGeneralOrderReq;
import com.umpay.dto.merAccess.res.consume.ConsumeGeneralOrderRes;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/* ******************  类说明  *********************
 * class       :  ConsumeGeneralOrderController
 * @author     :  ncc
 * @date       :  2018年3月15日 上午11:15:54
 * @version    :  1.0  
 * description :  业务下单
 * @see        :                        
 * ************************************************/   
@RestController
@SuppressWarnings("unchecked")
public class ConsumeGeneralOrderController extends AbstractController {

    private static final Logger log = LogManager.getLogger(ConsumeGeneralOrderController.class);

    @Autowired
    private ConsumeBusinessService consumeBusiness;

    @PostMapping("/consume/genaralOrder")
    @ReceiveEntity(type = ConsumeGeneralOrderReq.class)
    public Message<ConsumeGeneralOrderRes> consumeDebitcardReq(HttpServletRequest request, HttpServletResponse response) {
        
    	UMFRequest<ConsumeGeneralOrderReq> umfRequest = (UMFRequest<ConsumeGeneralOrderReq>) request.getAttribute(UMFRequest.REQUEST);
        log.info(String.format("业务下单接入接收请求参数[%s]", umfRequest));
        ConsumeGeneralOrderReq genaralOrderReq = umfRequest.getMessage();
        Message<ConsumeGeneralOrderRes> genaralOrderRes = this.consumeBusiness.consumeGeneralOrder(genaralOrderReq);

        return responseMsg(genaralOrderRes, response);
    }
}
